package com.xiangban.xiangbanmall.controller;

import com.xiangban.xiangbanmall.aop.Permission;
import com.xiangban.xiangbanmall.model.TUserRecommend;
import com.xiangban.xiangbanmall.model.res.ApiResult;
import com.xiangban.xiangbanmall.service.MemberRecommendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/11/3 11:00
 */
@RestController
@RequestMapping("/api/mall/member_recommend/")
@Api(tags = "会员推荐")
public class MemberRecommendController {

    @Autowired
    private MemberRecommendService memberRecommendService;


    @RequestMapping("/get_QR_code")
    @ApiOperation("二维码生成")
    @Permission
    public ApiResult<Object> getQRCode() throws Exception {
        return ApiResult.newSuccess(memberRecommendService.getQRCode());
    }

    @RequestMapping("/bind_recommend_user")
    @ApiOperation("绑定推荐用户")
    @Permission
    public ApiResult<Object> bindRecommendUser(@RequestBody Map<String,String> map) throws Exception {
        memberRecommendService.bindRecommendUser(map);
        return ApiResult.newSuccess();
    }

    @RequestMapping("/get_recommended_record")
    @ApiOperation("推荐记录")
    @Permission
    public ApiResult<Object> getRecommendedRecord(){
        return ApiResult.newSuccess(memberRecommendService.getRecommendedRecord());
    }

    @RequestMapping("/get_user_recommended")
    @ApiOperation("是否推荐人")
    @Permission
    public ApiResult<Object> getUserRecommended(@RequestBody TUserRecommend recommend){
        return ApiResult.newSuccess(memberRecommendService.getUserRecommended(recommend));
    }
}
